<template>
	<view class="paySuccess-wrap flex-col" v-if="inquiry">
		<image class="paySuccess-pic" src="https://cdn.quantifynet.cn/dti/icon_pay_succeed@2x.png"></image>
		<text class="paySuccess-info">付款成功</text>
		<text class="paySuccess-word">支付成功后{{ time }}秒直接跳转商城主页</text>
		<view class="paySuccess-btn">
			<view class="paySuccess-btn-left flex-col" @click="gotoOrderInfo">查看订单</view>
			<view class="paySuccess-btn-right flex-col" @click="gotoIndex">返回首页({{ time }}S)</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			orderId: '',
			time: 5,
			timer: null
		};
	},
	onLoad(option) {
		this.orderId = option.orderId;
		this.timer = setInterval(() => {
			if (this.time > 1) {
				this.time--;
			} else {
				clearInterval(this.timer);
				uni.reLaunch({
					url: '/pages/index/index'
				});
			}
		}, 1000);
	},
	onShow() {},
	onHide() {},
	onUnload() {
		clearInterval(this.timer);
	},
	methods: {
		gotoIndex() {
			clearInterval(this.timer);
			uni.reLaunch({
				url: '/pages/index/index'
			});
		},

		gotoOrderInfo() {
			clearInterval(this.timer);
			uni.reLaunch({
				url: '/pages-client/order/drugOrderList'
			});
		}
	}
};
</script>

<style lang="less">
.paySuccess-wrap {
	height: 100vh;
	background-color: #fff;
	padding-top: 63rpx;
	align-items: center;

	.paySuccess-pic {
		width: 134rpx;
		height: 135rpx;
	}
	.paySuccess-info {
		font-size: 32rpx;
		font-family: STSongti-SC-Bold, STSongti-SC;
		font-weight: bold;
		color: #000000;
		margin-top: 32rpx;
	}
	.paySuccess-word {
		font-size: 24rpx;
		font-family: STSongti-SC-Regular, STSongti-SC;
		font-weight: 400;
		color: #777676;

		margin-top: 16rpx;
	}
	.paySuccess-btn {
		z-index: auto;
		width: 490rpx;
		height: 82rpx;
		margin-top: 47rpx;
		flex-direction: row;
		display: flex;
		justify-content: space-between;
		.paySuccess-btn-left {
			width: 220rpx;
			height: 82rpx;
			background: #891e07;
			border-radius: 8rpx;
			font-size: 28rpx;
			font-family: STSongti-SC-Regular, STSongti-SC;
			font-weight: 400;
			color: #ffffff;
			align-items: center;
			justify-content: center;
		}
		.paySuccess-btn-right {
			width: 220rpx;
			height: 82rpx;
			border-radius: 8rpx;
			border: 2rpx solid #891e07;
			font-size: 28rpx;
			font-family: STSongti-SC-Regular, STSongti-SC;
			font-weight: 400;
			color: #891e07;
			align-items: center;
			justify-content: center;
		}
	}
}
</style>
